package com.mediacloud.app.newsmodule.activity;

import android.os.Bundle;
import androidx.fragment.app.FragmentTransaction;

import com.mediacloud.app.model.news.kt.TypeX;
import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.newsmodule.fragment.album.VodAlbumItemDetailFragment;
import com.mediacloud.app.newsmodule.utils.Addintegral;
import com.mediacloud.app.reslib.enums.AppFactoryGlobalConfig;
import com.mediacloud.app.reslib.enums.AppFactoryGlobalConfig.ServerAppConfigInfo.NavigateBarStyle;

import static com.mediacloud.app.reslib.enums.AppFactoryGlobalConfig.getAppServerConfigInfo;

import com.mediacloud.app.model.activity.BaseBackActivity;
import com.mediacloud.app.model.news.CatalogItem;
import com.mediacloud.app.reslib.enums.TitileType;

/**
 * 剧集详情列表页
 * @author x
 *
 */
public class AlbumItemDetailFragmentActivity extends BaseBackActivity {

	VodAlbumItemDetailFragment fragment;
	CatalogItem catalogItem;
	CatalogItem navigate;
	int type=-1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		catalogItem=getIntent().getParcelableExtra("data");
		navigate=getIntent().getParcelableExtra("catalog");
		if(catalogItem==null||navigate==null)
			return;
		type=catalogItem.getCatalogStyle();
		catalogItem.setCatalogStyle(0);
		fragment=new VodAlbumItemDetailFragment();
		Bundle bundle=new Bundle();
		bundle.putParcelable("catalog", catalogItem);
		bundle.putParcelable("data", navigate);
		bundle.putString("id", catalogItem.getCatid());
		fragment.setArguments(bundle); 
		FragmentTransaction transaction=getSupportFragmentManager().beginTransaction();
		transaction.replace(R.id.topicListContent, fragment);
		transaction.show(fragment);
		transaction.commitNowAllowingStateLoss();
		Addintegral.addintegral(this,2,null);
		setNewsTitle();
	}

	protected void setNewsTitle()
	{
		/*if(!needLoadTopSecondBgSkin()&&!TextUtils.isEmpty(getServerConfigTitle()))
		{
			setTitle(getServerConfigTitle());
		}
		else if(isNavigateTitle()&&navigate!=null)
		{
			setTitle(navigate.getCatname());
		}
		else if(catalogItem!=null)
		{
			setTitle(catalogItem.getCatname());
		}*/

		int base= AppFactoryGlobalConfig.getAppServerConfigInfo(this).getBase();
		if(base== TitileType.FRAME)
		{
			setFrameTypeTitle();
		}
		else  if(base== TitileType.NAVIGATE)
		{
			setTitle(navigate!=null?navigate.getCatname():"");
		}
		else  if(base== TitileType.NEWS_TITLE)
		{
			setTitle(catalogItem!=null?catalogItem.getCatname():"");
		}
		else  if(base== TitileType.NOTITLE)
		{
			setTitle("");
		}
	}

	@Override
	public int getLayoutResID() {
		return R.layout.aappfactory_activity_fragment_topicdetail_detail;
	}
	@Override
	protected boolean needLoadTopSecondBgSkin() 
	{
		return super.subClassgetNeedTopSecondBgSkin();
	}
	@Override
	protected NavigateBarStyle getNewsDetailNavigateBarStyle()
	{
		if(TypeX.OTHER.ALBUM_VIDEO==type)
			return getAppServerConfigInfo(this).getVideoAlbumNewsBar();
		if(TypeX.OTHER.ALBUM_AUDIO==type)
			return getAppServerConfigInfo(this).getAudioAlbumNewsBar();
		return null;
	}
}